package com.yx.filemanager;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yx.filemanager.util.FileUtils;

import java.util.List;

/**
 * Created by yx on 2017/8/31 0031.
 */

class FileAdapter extends BaseQuickAdapter<FileInfo, BaseViewHolder> {
    public FileAdapter(List<FileInfo> data) {
        super(R.layout.ui_file_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FileInfo item) {
        if (item.isDir()) {
            helper.setVisible(R.id.tv_file_size, false);
            helper.setBackgroundRes(R.id.iv_logo, R.drawable.vector_drawable_ic_folder);
        } else {
            helper.setVisible(R.id.tv_file_size, true);
            if (item.getFileSize() > 0) {
                helper.setText(R.id.tv_file_size, FileUtils.formatFileSize(item.getFileSize()));
            }
            helper.setBackgroundRes(R.id.iv_logo, R.drawable.vector_drawable_ic_file);
        }
        helper.setText(R.id.tv_file_name, item.getFileName());
    }
}
